<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Theory of Operation - Zend Framework Manual</title>

    <link href="../css/shCore.css" rel="stylesheet" type="text/css" />
    <link href="../css/shThemeDefault.css" rel="stylesheet" type="text/css" />
    <link href="../css/styles.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Zend Framework</h1>
<h2>Programmer's Reference Guide</h2>
<ul>
    <li><a href="../en/zend.config.theory_of_operation.html">Inglês (English)</a></li>
    <li><a href="../pt-br/zend.config.theory_of_operation.html">Português Brasileiro (Brazilian Portuguese)</a></li>
</ul>
<table width="100%">
    <tr valign="top">
        <td width="85%">
            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.config.introduction.html">Introduction</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.config.html">Zend_Config</a></span><br />
                        <span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.config.adapters.ini.html">Zend_Config_Ini</a></div>
                    </td>
                </tr>
            </table>
<hr />
<div id="zend.config.theory_of_operation" class="section"><div class="info"><h1 class="title">Theory of Operation</h1></div>
    

    <p class="para">
        Configuration data are made accessible to the <span class="classname">Zend_Config</span> constructor
        through an associative array, which may be multi-dimensional, in order to support
        organizing the data from general to specific. Concrete adapter classes
        adapt configuration data from storage to produce the associative array for the
        <span class="classname">Zend_Config</span> constructor. User scripts may provide such arrays
        directly to the <span class="classname">Zend_Config</span> constructor, without using an adapter
        class, since it may be appropriate to do so in certain situations.
    </p>

    <p class="para">
        Each configuration data array value becomes a property of the
        <span class="classname">Zend_Config</span> object. The key is used as the property name. If a value
        is itself an array, then the resulting object property is created as a new
        <span class="classname">Zend_Config</span> object, loaded with the array data. This occurs
        recursively, such that a hierarchy of configuration data may be created with any number of
        levels.
    </p>

    <p class="para">
        <span class="classname">Zend_Config</span> implements the <em class="emphasis">Countable</em> and
        <em class="emphasis">Iterator</em> interfaces in order to facilitate simple access to
        configuration data. Thus, one may use the
        <a href="http://php.net/count" class="link external">&raquo;  <span class="methodname">count()</span></a>
        function and <acronym class="acronym">PHP</acronym> constructs such as
        <a href="http://php.net/foreach" class="link external">&raquo; <em class="emphasis">foreach</em></a> with
        <span class="classname">Zend_Config</span> objects.
    </p>

    <p class="para">
        By default, configuration data made available through <span class="classname">Zend_Config</span> are
        read-only, and an assignment (e.g.,
        <strong class="command">$config-&gt;database-&gt;host = &#039;example.com&#039;;</strong>)
        results in a thrown exception. This default behavior may be overridden through the
        constructor, however, to allow modification of data values. Also, when modifications are
        allowed, <span class="classname">Zend_Config</span> supports unsetting of values (i.e.
         <span class="methodname">unset($config-&gt;database-&gt;host)</span>). The
         <span class="methodname">readOnly()</span> method can be used to determine if modifications to a
        given <span class="classname">Zend_Config</span> object are allowed and the
         <span class="methodname">setReadOnly()</span> method can be used to stop any further modifications
        to a <span class="classname">Zend_Config</span> object that was created allowing modifications.
    </p>

    <blockquote class="note"><p><b class="note">Note</b>: 
        <p class="para">
            It is important not to confuse such in-memory modifications with saving
            configuration data out to specific storage media. Tools for creating and modifying
            configuration data for various storage media are out of scope with respect to
            <span class="classname">Zend_Config</span>. Third-party open source solutions are readily
            available for the purpose of creating and modifying configuration data for various
            storage media.
        </p>
    </p></blockquote>

    <p class="para">
        Adapter classes inherit from the <span class="classname">Zend_Config</span> class since they utilize
        its functionality.
    </p>

    <p class="para">
        The <span class="classname">Zend_Config</span> family of classes enables configuration data to be
        organized into sections. <span class="classname">Zend_Config</span> adapter objects may be loaded
        with a single specified section, multiple specified sections, or all sections
        (if none are specified).
    </p>

    <p class="para">
        <span class="classname">Zend_Config</span> adapter classes support a single inheritance model that
        enables configuration data to be inherited from one section of configuration data
        into another. This is provided in order to reduce or eliminate the need for
        duplicating configuration data for different purposes. An inheriting section
        may also override the values that it inherits through its parent section.
        Like <acronym class="acronym">PHP</acronym> class inheritance, a section may inherit from a parent section,
        which may inherit from a grandparent section, and so on, but multiple inheritance
        (i.e., section C inheriting directly from parent sections A and B) is not supported.
    </p>

    <p class="para">
        If you have two <span class="classname">Zend_Config</span> objects, you can merge them into a single
        object using the  <span class="methodname">merge()</span> function. For example, given
        <var class="varname">$config</var> and <var class="varname">$localConfig</var>, you can merge data from
        <var class="varname">$localConfig</var> to <var class="varname">$config</var> using
        <strong class="command">$config-&gt;merge($localConfig);</strong>. The items in
        <var class="varname">$localConfig</var> will override any items with the same name in
        <var class="varname">$config</var>.
    </p>

    <blockquote class="note"><p><b class="note">Note</b>: 
        <p class="para">
            The <span class="classname">Zend_Config</span> object that is performing the merge must have
            been constructed to allow modifications, by passing <b><tt>TRUE</tt></b> as the
            second parameter of the constructor. The  <span class="methodname">setReadOnly()</span>
            method can then be used to prevent any further modifications after the merge is
            complete.
        </p>
    </p></blockquote>
</div>
        <hr />

            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.config.introduction.html">Introduction</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.config.html">Zend_Config</a></span><br />
                        <span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.config.adapters.ini.html">Zend_Config_Ini</a></div>
                    </td>
                </tr>
            </table>
</td>
        <td style="font-size: smaller;" width="15%"> <style type="text/css">
#leftbar {
	float: left;
	width: 186px;
	padding: 5px;
	font-size: smaller;
}
ul.toc {
	margin: 0px 5px 5px 5px;
	padding: 0px;
}
ul.toc li {
	font-size: 85%;
	margin: 1px 0 1px 1px;
	padding: 1px 0 1px 11px;
	list-style-type: none;
	background-repeat: no-repeat;
	background-position: center left;
}
ul.toc li.header {
	font-size: 115%;
	padding: 5px 0px 5px 11px;
	border-bottom: 1px solid #cccccc;
	margin-bottom: 5px;
}
ul.toc li.active {
	font-weight: bold;
}
ul.toc li a {
	text-decoration: none;
}
ul.toc li a:hover {
	text-decoration: underline;
}
</style>
 <ul class="toc">
  <li class="header home"><a href="manual.html">Programmer's Reference Guide</a></li>
  <li class="header up"><a href="manual.html">Programmer's Reference Guide</a></li>
  <li class="header up"><a href="reference.html">Zend Framework Reference</a></li>
  <li class="header up"><a href="zend.config.html">Zend_Config</a></li>
  <li><a href="zend.config.introduction.html">Introduction</a></li>
  <li class="active"><a href="zend.config.theory_of_operation.html">Theory of Operation</a></li>
  <li><a href="zend.config.adapters.ini.html">Zend_Config_Ini</a></li>
  <li><a href="zend.config.adapters.json.html">Zend_Config_Json</a></li>
  <li><a href="zend.config.adapters.xml.html">Zend_Config_Xml</a></li>
  <li><a href="zend.config.adapters.yaml.html">Zend_Config_Yaml</a></li>
 </ul>
 </td>
    </tr>
</table>

<script type="text/javascript" src="../js/shCore.js"></script>
<script type="text/javascript" src="../js/shAutoloader.js"></script>
<script type="text/javascript" src="../js/main.js"></script>

</body>
</html>